<HTML>
    <HEAD>
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
  <title>运行时信息测试页面</title>
  <script type="text/javascript" src="./js/service.js"></script>
  <script type="text/javascript" src="/usr/share/javascript/jquery/jquery.min.js"></script>
  <script src="./js/qwebchannel.js"></script>
      <TITLE>运行时信息测试页面</TITLE>
      <SCRIPT language=JavaScript>
              var websocket_url = 'ws://localhost:12345';
              var websocket = null;

              if (websocket === null) {
                  websocket = new WebSocket(websocket_url);
                  websocket.onopen = function () {
                      console.log("connect websocketserver success");
                  }
              } else {
                  websocket.close();
                  websocket = null;
              }

              // function getIoSpeed() {
              //     console.log("getIoSpeed")
              //     new QWebChannel(websocket,function(channel){
              //             var runinfo = channel.objects.runinfo;
              //             runinfo.sendText.connect(function(message) {
              //                 console.log("Received message: " + message);
              //                 document.getElementById("res").value = message;
              //             });
              //             runinfo.getIoSpeed();
              //             }
              //         );
              // }
              function getNetSpeed() {
                  console.log("getNetSpeed")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var runinfo = channel.objects.runinfo;
                          runinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          runinfo.getNetSpeed(pid);
                          }
                      );
              }

              function getDiskRate() {
                  console.log("getDiskRate")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var runinfo = channel.objects.runinfo;
                          runinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          runinfo.getDiskRate(pid);
                          }
                      );
              }

              // function getMainboardTemperature() {
              //     console.log("getMainboardTemperature")
              //     new QWebChannel(websocket,function(channel){
              //             var runinfo = channel.objects.runinfo;
              //             runinfo.sendText.connect(function(message) {
              //                 console.log("Received message: " + message);
              //                 document.getElementById("res").value = message;
              //             });
              //             runinfo.getMainboardTemperature();
              //             }
              //         );
              // }
              function getCpuTemperature() {
                  console.log("getCpuTemperature")
                  new QWebChannel(websocket,function(channel){
                          var runinfo = channel.objects.runinfo;
                          runinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          runinfo.getCpuTemperature();
                          }
                      );
              }
              function getDiskTemperature() {
                  console.log("getDiskTemperature")
                  pid = $("#pid").val()
                  new QWebChannel(websocket,function(channel){
                          var runinfo = channel.objects.runinfo;
                          runinfo.sendText.connect(function(message) {
                              console.log("Received message: " + message);
                              document.getElementById("res").value = message;
                          });
                          runinfo.getDiskTemperature(pid);
                          }
                      );
              }
        //-->
      </SCRIPT>
      <META content="MSHTML 6.00.2900.6287" name=GENERATOR>
      <style>
        table tr td{padding: 5px;}
      </style>
  
    </HEAD>
    <BODY>
      <div style="margin:30 5 20 5">
        <div>
          <!-- <input onclick="getIoSpeed()" type="button" value="实时IO读写速率"  style="width: 120px; height: 50px"> -->
          <input onclick="getNetSpeed()" type="button" value="实时网速"  style="width: 100px; height: 50px">
          <input onclick="getDiskRate()" type="button" value="磁盘转速"  style="width: 100px; height: 50px">
          <!-- <input onclick="getMainboardTemperature()" type="button" value="实时主板温度"  style="width: 100px; height: 50px"> -->
          <input onclick="getCpuTemperature()" type="button" value="实时CPU温度"  style="width: 100px; height: 50px">
          <input onclick="getDiskTemperature()" type="button" value="实时硬盘温度"  style="width: 100px; height: 50px">
        </div>
        <div id="input_box2">
            <h3>硬盘绝对路径:</h3>
            <label>
              <input type="text" id="pid" style="height: 30px; width: 200px;" placeholder="硬盘绝对路径">
            </label>
          </div>
        <div style="margin-top:20">
          <div align=left style="margin:5 0 5 0">回复：</div>
          <div>
          <textarea id="res" style="width:1000px;height:500px" ></textarea>
          </div>
        </div>
      </div>
    </BODY>
  </HTML>
  